import math

def word_to_number(word):
    numbers = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}
    return numbers.get(word, -1)

def is_prime(n):
    if n <= 1:
        return False
    if n <= 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    i = 5
    while i * i <= n:
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

def find_nearest_prime(number):
    if len(number) != 3 or not number.isdigit():
        return "Wrong input"
    num = int(number)
    if is_prime(num):
        return num
    lower_prime = num
    upper_prime = num
    while True:
        if is_prime(lower_prime):
            return lower_prime
        if is_prime(upper_prime):
            return upper_prime
        lower_prime -= 1
        upper_prime += 1

input_words = input("").split()
number = ''.join(str(word_to_number(word)) for word in input_words)
result = find_nearest_prime(number)
print(result)
